import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '@/views/Login'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
// 使用路由加载项哈
// import User from
const User = () => import(/* webpackChunkName:"User" */'@/views/User')
// import Edit from '@/views/User/deit'
const Edit = () => import(/* wabpackChunkName:"Edit" */'@/views/User/deit')
//  import Search from '@/views/search'
const Search = () => import(/* wabpackChunkName:"Search" */'@/views/search')
// import Result from '@/views/search/Result'
const Result = () => import(/* wabpackChunkName:"Result" */'@/views/search/Result')
// import Article from '@/views/article'
const Article = () => import(/* wabpackChunkName:"Article" */'@/views/article')
// import Xiaoai from '@/views/xiaoai'
const Xiaoai = () => import(/* wabpackChunkName:"Xiaoai" */'@/views/xiaoai')
Vue.use(VueRouter)

const routes = [
  // 路由规则 我们 自己编写
  {
    path: '/',
    redirect: '/layout'// 重定向
  },
  { // 登录
    path: '/login',
    component: Login
  },
  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/home', // 重定向
    // 二级路由
    children: [
      { // 首页
        path: 'home',
        component: Home
      }, { // 用户
        path: 'user',
        component: User
      }
    ]
  },
  // 搜索页面的路由哈
  {
    path: '/search',
    component: Search
  },
  {
    path: '/search/:keyword',
    component: Result
  },
  // 文章详情状态
  {
    path: '/article',
    component: Article
  },
  // 编辑个人信息
  {
    path: '/edit',
    component: Edit
  },
  // 小爱同学的
  {
    path: '/xiaoai',
    component: Xiaoai
  }
]

const router = new VueRouter({
  routes
})

export default router
